<!--
 * @Author       : xh
 * @Date         : 2022-10-21 14:47:13
 * @LastEditors: y001554
 * @FileName     :   
-->
<template>
  <el-config-provider :locale="locale" namespace="el" size="default">
    <router-view />
    <!--圣杯布局 -->
  </el-config-provider>
</template>
<script setup>
import actions from './action'

import { setToken } from '@/utils/auth'
import { useAppStore } from '@/store/app'

import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import { onMounted } from 'vue'
let locale = $ref(zhCn) //中文

// import en from 'element-plus/lib/locale/lang/en'
// let locale = $ref(en) //english

const appStore = useAppStore()
const microMode = useMicro()
const { ifMicroMode, onGlobalStateChange } = microMode

const settings = computed(() => {
  return appStore.settings
})
onBeforeMount(() => {
  //set tmp token when setting isNeedLogin false
  if (!settings.value.isNeedLogin) setToken(settings.value.tmpToken)
})
onMounted(() => {
  // console.log('onMounted', ifMicroMode, onGlobalStateChange)
  if (ifMicroMode && onGlobalStateChange) {
    // debugger
    onGlobalStateChange((arg) => {
      // debugger
      appStore.M_sidebar_opened(arg.opened || false)
    })
  }
})
</script>
